package com.itany.springcloud.springcloudeurekaopenfeignconsumer.service;

import com.itany.springcloud.springcloudcommon.entity.User;
import com.itany.springcloud.springcloudcommon.vo.ResponseResult;
import com.itany.springcloud.springcloudeurekaopenfeignconsumer.service.fallback.UserServiceFallback;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.*;

@Service
//@FeignClient(value = "springcloud-eureka-provider",fallback = UserServiceFallback.class)
@FeignClient(value = "springcloud-eureka-zuul",fallback = UserServiceFallback.class)
public interface UserService {


//    @GetMapping("/users")
    @GetMapping("/v1/userService/users")
    public ResponseResult findAll();


//    @GetMapping("/users/{id}")
    @GetMapping("/v1/userService/users/{id}")
    public ResponseResult findById(@PathVariable("id") Integer id);


//    @PostMapping("/users")
    @PostMapping("/v1/userService/users")
    public ResponseResult add(@RequestParam("username") String username,
                              @RequestParam("password") String password);

//    @PostMapping("/users/add2")
    @PostMapping("/v1/userService/users/add2")
    public ResponseResult add2(@RequestBody User user);


    //SpringCloud 2.1 以后
//    @PostMapping("/users/add3")
//    @PostMapping("/v1/userService/users/add3")
//    public ResponseResult add3(@SpringQueryMap User user);

//    @DeleteMapping("/users/{id}")
    @DeleteMapping("/v1/userService/users/{id}")
    public ResponseResult remove(@PathVariable("id") Integer id);


//    @PutMapping("/users")
    @PutMapping("/v1/userService/users")
    public ResponseResult modify(@RequestParam("id") Integer id,
                                 @RequestParam("username") String username,
                                 @RequestParam("password") String password);




}
